package com.hrpmar.controller;

import com.hrpmar.pojo.Purdetails;
import com.hrpmar.pojo.Purplan;
import com.hrpmar.service.PurplanService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by c on 2017-11-17.
 */
@Controller
@RequestMapping("/pur")
public class PurplanController {

    @Resource
    private PurplanService purplanService;

    @RequestMapping("/searchOne")
    public String searchPurplan(String planNum, Model model){
        Purplan pur = purplanService.searchPurplanByNum(planNum);
        List<Purdetails> list = purplanService.searchDetails(planNum);
        model.addAttribute("pur",pur);
        model.addAttribute("list",list);
        return "pur/purdetails";
    }

    @RequestMapping("/purEdit")
    public String purEdit(String planNum, Model model){
        Purplan pur = purplanService.searchPurplanByNum(planNum);
        List<Purdetails> list = purplanService.searchDetails(planNum);
        model.addAttribute("pur",pur);
        model.addAttribute("list",list);
        return "pur/purEdit";
    }

}
